		
clear all	 
set maxvar 10000
	 
cd "$data"
use "besip.dta", clear 


	*drop if leftRightW20==9999 & immigSelfW20==9999 & immigEconW20==9999 & immigCulturalW20==9999 & redistSelfW20==9999 & EUIntegrationSelfW20==9999 & enviroGrowthW20==9999
	
	
foreach var of varlist leftRightW20 taxSpendSelfW20 immigSelfW20 immigEconW20 immigCulturalW20 redistSelfW20 EUIntegrationSelfW20 enviroGrowthW20 {
	regress `var' i.votertype if `var'<11 & samplelimit==1, robust 
	margins, at(votertype=(0 1 2)) post
	estimates store est_`var'	
}

cd "$data/votertype"



coefplot (est_leftRightW20, label() msymbol(circle_hollow) mcolor(gs2%80) ///
    ciopts(color(gs2%80))), horizontal byopts(legend(off)) ///
    xline(5, lcolor(gs5) lpattern(dash)) title("left-right") ///
    ylabel(1 "PNV" 2 "PV" 3 "RV", nogrid) ///
    yline(1 2 3, lcolor(gs12%30) lpattern(dash) lwidth(thin)) ///
    xlabel(, grid glcolor(gs12%30) glpattern(dash) glwidth(thin)) ///
    yscale(range(0.5 3.5)) ///
    graphregion(color(white) lcolor(none)) ///
    plotregion(lcolor(none))

  graph save "leftright.gph", replace 

  coefplot (est_immigSelfW20, label() msymbol(circle_hollow) mcolor(gs2%80) ///
    ciopts(color(gs2%80))), horizontal byopts(legend(off)) ///
    xline(5, lcolor(gs5) lpattern(dash)) title("immigration 1") ///
    ylabel(1 "PNV" 2 "PV" 3 "RV", nogrid) ///
       yline(1 2 3, lcolor(gs12) lpattern(dash) lwidth(thin)) /// 
    xlabel(, grid glcolor(gs12%30) glpattern(dash) glwidth(thin)) ///
    graphregion(color(white) lcolor(none)) ///
    plotregion(lcolor(none))
  graph save "immigration1.gph", replace 
  
  
   coefplot (est_immigEconW20, label() msymbol(circle_hollow) mcolor(gs2%80) ///
    ciopts(color(gs2%80))), horizontal byopts(legend(off)) ///
    xline(5, lcolor(gs5) lpattern(dash)) title("immigration 2") ///
    ylabel(1 "PNV" 2 "PV" 3 "RV", nogrid) ///
    yline(1 2 3, lcolor(gs12) lpattern(dash) lwidth(thin)) /// 
    xlabel(, grid glcolor(gs12%30) glpattern(dash) glwidth(thin)) ///
    graphregion(color(white) lcolor(none)) ///
    plotregion(lcolor(none))
  graph save "immigration2.gph", replace 
  
  
   coefplot (est_immigCulturalW20, label() msymbol(circle_hollow) mcolor(gs2%80) ///
    ciopts(color(gs2%80))), horizontal byopts(legend(off)) ///
    xline(5, lcolor(gs5) lpattern(dash)) bylabel(with controls) ///
    title("immigration 3") ///
    ylabel(1 "PNV" 2 "PV" 3 "RV", nogrid) ///
    yline(1 2 3, lcolor(gs12) lpattern(dash) lwidth(thin)) /// 
	xlabel(, grid glcolor(gs12%30) glpattern(dash) glwidth(thin)) ///
    graphregion(color(white) lcolor(none)) ///
    plotregion(lcolor(none))
  graph save "immigration3.gph", replace 
  
    coefplot (est_redistSelfW20, label() msymbol(circle_hollow) mcolor(gs2%80) ///
    ciopts(color(gs2%80))), horizontal byopts(legend(off)) ///
    xline(5, lcolor(gs5) lpattern(dash)) title("redistribution") ///
    ylabel(1 "PNV" 2 "PV" 3 "RV", nogrid) ///
    yline(1 2 3, lcolor(gs12) lpattern(dash) lwidth(thin)) /// 
    xlabel(, grid glcolor(gs12%30) glpattern(dash) glwidth(thin)) ///
    graphregion(color(white) lcolor(none)) ///
    plotregion(lcolor(none))
  graph save "redistribution.gph", replace 
  
  
    coefplot (est_taxSpendSelfW20, label() msymbol(circle_hollow) mcolor(gs2%80) ///
    ciopts(color(gs2%80))), horizontal byopts(legend(off)) ///
    xline(5, lcolor(gs5) lpattern(dash)) title("spending") ///
    ylabel(1 "PNV" 2 "PV" 3 "RV", nogrid) ///
    yline(1 2 3, lcolor(gs12) lpattern(dash) lwidth(thin)) /// 
    xlabel(, grid glcolor(gs12%30) glpattern(dash) glwidth(thin)) ///
    graphregion(color(white) lcolor(none)) ///
    plotregion(lcolor(none))
  graph save "spending.gph", replace 
    
  
      coefplot (est_EUIntegrationSelfW20, label() msymbol(circle_hollow) mcolor(gs2%80) ///
    ciopts(color(gs2%80))), horizontal byopts(legend(off)) ///
    xline(5, lcolor(gs5) lpattern(dash)) title("EU Integration") ///
    ylabel(1 "PNV" 2 "PV" 3 "RV", nogrid) ///
    yline(1 2 3, lcolor(gs12) lpattern(dash) lwidth(thin)) /// 
    xlabel(, grid glcolor(gs12%30) glpattern(dash) glwidth(thin)) ///
    graphregion(color(white) lcolor(none)) ///
    plotregion(lcolor(none))
  graph save "EUIntegration.gph", replace  
  
  
        coefplot (est_enviroGrowthW20, label() msymbol(circle_hollow) mcolor(gs2%80) ///
    ciopts(color(gs2%80))), horizontal byopts(legend(off)) ///
    xline(5, lcolor(gs5) lpattern(dash)) title("environment") ///
    ylabel(1 "PNV" 2 "PV" 3 "RV", nogrid) ///
	yline(1 2 3, lcolor(gs12) lpattern(dash) lwidth(thin)) ///
    xlabel(, grid glcolor(gs12%30) glpattern(dash) glwidth(thin)) ///
    graphregion(color(white) lcolor(none)) ///
    plotregion(lcolor(none))
  graph save "environment.gph", replace   
  

	
graph combine leftright.gph redistribution.gph spending.gph immigration1.gph immigration2.gph immigration3.gph environment.gph  EUIntegration.gph, xcommon ycommon col(2) ysize(7) xsize(5)
graph save "${figures}/votertype_merged.gph", replace   
graph export "${figures}/votertype_merged.png", as(png) replace 
